import QtQuick 1.0
import com.nokia.meego 1.0
import com.meego.extras 1.0

PageStackWindow {
     id:rootWindow
     showStatusBar: true
     signal buttonClicked;
     //function start(){text.text="started";buttonClicked()}
    function start(){text.text="Running";buttonClicked()}
     function settings(){
if (rdesktop.checked){var a="0"} else {var a="1"};
if (rphone.checked){var b="0"} else {var b="1"};
if (player.checked){var c="0"} else {var c="1"};
if (mode.checked){var d="0"} else {var d="1"};
var set=(a+b+c+d).toString();
var frames=sl2.value.toString();
var addr= ip.text;
var com=set+frames+addr;
con.savesettings(com);
banner0.show();
}
	
//Switch on off
Rectangle {id: page
    	   width: parent.width; height:parent.height;
    	   color: "black"
    	   anchors.horizontalCenter: parent.horizontalCenter; 
    	   anchors.verticalCenter:parent.verticalCenter;

Switch{id:switchComponent
anchors.verticalCenter:parent.verticalCenter;
anchors.horizontalCenter:parent.horizontalCenter;
}
//end of switch
Text{id:text

 	color:"red"
	anchors.bottom: switchComponent.top
	anchors.horizontalCenter: switchComponent.horizontalCenter
         //text: switchComponent.checked ? "GROUNDWORK ON" & start()  : "Press to Start"
	//text: switchComponent.checked ? "GROUNDWORK ON" && start()  : "Press to Start"
		text: switchComponent.checked ? start() : "Press to Start"
    	   font.pixelSize: 30
    	   smooth:true}
   }
Button {
		anchors.bottom:page.bottom
		anchors.horizontalCenter:page.horizontalCenter
                text: "Settings"
                onClicked: sheet.open()
            }

 Sheet {
        id: sheet

        acceptButtonText: "Save"
        rejectButtonText: "Cancel"
        title: BusyIndicator {id:title;
            anchors.centerIn: parent; running: sheet.status == DialogStatus.Open;
        }


	Column {
                id: col2
                //anchors.verticalCenter: parent.verticalCenter
		anchors.bottom:parent.bottom
		anchors.horizontalCenter: parent.horizontalCenter
                spacing: 4

		Label { text: "Record Session to Desktop" ; color: "black"; }
                ButtonRow {id:a
                Button { id: rdesktop; text: "OFF"; }
                Button { text: "ON" ; }
            		  }
		Label { text: "Record Session to Phone" ; color: "black"}
                ButtonRow {id:b
                Button { id: rphone;text: "OFF"; }
                Button { text: "ON" ; }
            		  }
		Label { text: "Viewer" ; color: "black"; }
                ButtonRow {id:c
                Button { id: player; text: "MPLAYER" ; }
                Button { text: "VLC" ; }
            		  }
		Label { text: "RAW MODE" ; color: "black" }
                ButtonRow {id:d
                Button { id: mode;text: "OFF";  }
                Button { text: "ON"; 
			}
            		  }
TextField {id:ip
                
placeholderText: "Desktop IP Adress"
                        inputMethodHints: Qt.ImhDigitsOnly | Qt.ImhNoPredictiveText
                    }
Row {
                Label { text: sl2.value.toFixed(2) ; color: "green"; width: 80 }
                Label { visible: screen.currentOrientation == Screen.Landscape; width: page.textColumnWidth; wrapMode: Text.Wrap; text: "Frames per Second" }
		Label { visible: screen.currentOrientation == Screen.Portrait; width: page.textColumnWidth; wrapMode: Text.Wrap; text: "FPS" }
                Slider { id:sl2; stepSize:1 ; valueIndicatorVisible: true; minimumValue:1 ; maximumValue:30 ; width:384;value:15}
            }


            }
        onAccepted: settings()
        //onRejected: label.text = "Rejected!"
}
	InfoBanner{
                id: banner0
                text: "Settings Saved"
               
                timerShowTime: 1*1000
                topMargin: 70
                leftMargin: 8
                  }

 		}
